package stackAndQueue;

public class MyQueue {
	public static int MAX = 5000;
	public int[] queue = new int[MAX];
	public int l,r,size;
	public MyQueue() {
		l = r = size = 0;
	}
	//[l,r)是有效数据， l==r意味队列为空
	public void offer(int val) {
		queue[r++] = val;
		size++;
	}
	
	public int poll() {
		size--;
		return queue[l++];
	}
	public int peek() {
		return queue[l];
	}
	public int size() {
		return size;
	}
	
	public boolean isEmpty() {
		return l==r;//或者size==0
	}
	public static void main(String[] args) {
		MyQueue queue = new MyQueue();
		System.out.println(queue.isEmpty());
		queue.offer(1);
		queue.offer(2);
		queue.offer(3);
		System.out.println("queue.size():"+queue.size());
		System.out.println(queue.poll());
		System.out.println("queue.size():"+queue.size());
		System.out.println(queue.poll());
		
	}
}
